import JSEncrypt from 'jsencrypt/bin/jsencrypt.min'
// 密钥对生成 http://web.chacuo.net/netrsakeypair

const publicKey = 'MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCIYfkOnjcraG6i4QwfOHa8G9kr7GJBKUBcKK6+dCq0qM2MaW/N7dXvL39VDU9i+BHksqlt1NB6J5EpVgy/x7nfT4CKXrJPqgwFPwMBbqUxVEvrF1nCNsLnmY+vdDiQdTmULVP38CNRFvBB4qsYF0GWArA/sgcYYaNq8XJxoOyaSQIDAQAB'

const privateKey = 'MIIBVAIBADANBgkqhkiG9w0BAQEFAASCAT4wggE6AgEAAkEAqhHyZfSsYourNxaY\n' +
    '7Nt+PrgrxkiA50efORdI5U5lsW79MmFnusUA355oaSXcLhu5xxB38SMSyP2KvuKN\n' +
    'PuH3owIDAQABAkAfoiLyL+Z4lf4Myxk6xUDgLaWGximj20CUf+5BKKnlrK+Ed8gA\n' +
    'kM0HqoTt2UZwA5E2MzS4EI2gjfQhz5X28uqxAiEA3wNFxfrCZlSZHb0gn2zDpWow\n' +
    'cSxQAgiCstxGUoOqlW8CIQDDOerGKH5OmCJ4Z21v+F25WaHYPxCFMvwxpcw99Ecv\n' +
    'DQIgIdhDTIqD2jfYjPTY8Jj3EDGPbH2HHuffvflECt3Ek60CIQCFRlCkHpi7hthh\n' +
    'YhovyloRYsM+IS9h/0BzlEAuO0ktMQIgSPT3aFAgJYwKpqRYKlLDVcflZFCKY7u3\n' +
    'UP8iWi1Qw0Y='

export const publicKey2 = '-----BEGIN PUBLIC KEY-----\n' +
    'MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDKbjBJceoYUjnMgVhCnn8gih6f\n' +
    '0Y6SWTapXscQZOaJSAUhFSJtpExrDGfTVhXhefQc8kx/ZjZhUrV46FxNwXOZpSVb\n' +
    'OeE2aaTnxKtlFB3mGXzHspIeULbLW8MjAYa4FKceRjJFGSqVWygPPCKz20Gg1dxZ\n' +
    'I0kySZejcTEwd5kGuQIDAQAB\n' +
    '-----END PUBLIC KEY-----\n'

export const privateKey2 = '-----BEGIN PRIVATE KEY-----\n' +
    'MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBAMpuMElx6hhSOcyB\n' +
    'WEKefyCKHp/RjpJZNqlexxBk5olIBSEVIm2kTGsMZ9NWFeF59BzyTH9mNmFStXjo\n' +
    'XE3Bc5mlJVs54TZppOfEq2UUHeYZfMeykh5QtstbwyMBhrgUpx5GMkUZKpVbKA88\n' +
    'IrPbQaDV3FkjSTJJl6NxMTB3mQa5AgMBAAECgYADC6laUYZuGz6XXxLO3ceX27we\n' +
    'N27nsMPrxGtGSd5WDmlVWBYOhDxKGAOv4Emv/L+5d8PC3uzOhgoI6aYJ3XE5xa6/\n' +
    'SD2m52x3g4HtOn2F9QwuSU7Uw9egvGUlPATdvPkuevuIBv4ff2AVpJpOhTWc911i\n' +
    'wrkCjHt4xSEeJy70yQJBAPN+jEMt8vZqOLjwBGCOxYQPngb9nrSaE08u5oFUr5U3\n' +
    'XJ9C3fmSYC5ZX+xYaZzBHNYFbvLV+J3G0+l9NABOYL8CQQDU07wDcH/s5taEWQtu\n' +
    '0f8zxJKyClqRGwLRacCcuqoISPP6iNgwLBKDokhRXG63+fqogsKyU70toLZy9h6o\n' +
    '2n6HAkEAkLieVS9yQNNRc1n0wA8bhipiGnWTZnRNFbsidawH0ABfpKjxlexSDjpA\n' +
    'sRC7dNeyc+I2104lvmD2gshPp/7tsQJBAKP4LVaJCkY+4u88m25aJECCJnM9PuGk\n' +
    '6drlmxwlRHL1oeNYIxeaHPmFwinNCRB9a/0AIXi6w3mv5GFV9fEpxWkCQDFdFkqr\n' +
    '5KRW0YB/NJwond94qB9/O3lDUG/yzDK45Iy/nvtSwF9+PwQu30Hpx5/LlZ3XWxPk\n' +
    'DE2aNLWezRX5YSc=\n' +
    '-----END PRIVATE KEY-----'
// 加密
export function encryptRSA(txt) {
    const encryptor = new JSEncrypt()
    encryptor.setPublicKey(publicKey) // 设置公钥
    return encryptor.encrypt(txt) // 对数据进行加密
}

// 解密
export function decryptRSA(txt) {
    const encryptor = new JSEncrypt()
    encryptor.setPrivateKey(publicKey) // 设置私钥
    return encryptor.decrypt(txt) // 对数据进行解密
}

// 解密
export function decryptRSAPub(txt) {
    const encryptor = new JSEncrypt()
    // 设置公钥
    encryptor.setPublicKey(publicKey)
    // 对数据进行解密
    return encryptor.decrypt(txt)
}
